package com.aiyun.securiy.login.security;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtils {


	public static String getCurrentUser(){
		SecurityContext securityContext = SecurityContextHolder.getContext();
		Authentication authentication = securityContext.getAuthentication();
		if (authentication != null && authentication.isAuthenticated()) {
			return authentication.getPrincipal().toString();
		}
		return "anymouse";
	}
}
